<%@ page import="com.roadjava.tutor.util.Constants" %>
<%@ page import="com.roadjava.tutor.bean.vo.UserVO" %>
<%@ page import="com.roadjava.tutor.bean.enums.RoleEnum" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <title>前台主界面</title>
  <jsp:include page="../common/common_resources.jsp"/>
</head>
<body>
<div class="layui-container">
  <!--头部片段-->
  <header>
    <div class="layui-row">
      <div class="layui-col-sm12">
        <img class="img-fluid" src="<%=request.getContextPath() %>/resources/images/logo.jpg"/>
      </div>
      <div class="layui-col-sm12">
        <ul class="layui-nav layui-bg-cyan">
          <c:choose>
            <c:when test="${sessionScope.user == null}">
              <li class="layui-nav-item layui-this">
                <a href="<%=request.getContextPath() %>/front/toStudentDemand" target="main">找学生</a>
              </li>
              <li class="layui-nav-item">
                <a href="<%=request.getContextPath() %>/front/toTeacherJob" target="main">找老师</a>
              </li>
              <li class="layui-nav-item">
                <a href="<%=request.getContextPath() %>/toRegister" target="main">用户注册</a>
              </li>
              <li class="layui-nav-item">
                <a href="<%=request.getContextPath() %>/toLogin" target="main">用户登录</a>
              </li>
            </c:when>
            <c:when test="${RoleEnum.STUDENT.cnName.equals(sessionScope.user.role)}">
              <li class="layui-nav-item">
                <a href="<%=request.getContextPath() %>/front/toTeacherJob" target="main">找老师</a>
              </li>
              <li class="layui-nav-item">
                <a href="javascript:;">欢迎学生:<c:out value="${sessionScope.user.userName}"/></a>
                <dl class="layui-nav-child"> <!-- 二级菜单 -->
                  <dd><a href="<%=request.getContextPath() %>/student/toMain">去管理页面</a></dd>
                  <dd><a href="<%=request.getContextPath() %>/logout">退出</a></dd>
                </dl>
              </li>
            </c:when>
            <c:when test="${RoleEnum.TEACHER.cnName.equals(sessionScope.user.role)}">
              <li class="layui-nav-item layui-this">
                <a href="<%=request.getContextPath() %>/front/toStudentDemand" target="main">找学生</a>
              </li>
              <li class="layui-nav-item">
                <a href="javascript:;">欢迎教师:<c:out value="${sessionScope.user.userName}"/></a>
                <dl class="layui-nav-child">
                  <dd><a href="<%=request.getContextPath() %>/teacher/toMain">去管理页面</a></dd>
                  <dd><a href="<%=request.getContextPath() %>/logout">退出</a></dd>
                </dl>
              </li>
            </c:when>
            <c:otherwise>
              <li class="layui-nav-item layui-this">
                <a href="<%=request.getContextPath() %>/front/toStudentDemand" target="main">找学生</a>
              </li>
              <li class="layui-nav-item">
                <a href="<%=request.getContextPath() %>/front/toTeacherJob" target="main">找老师</a>
              </li>
              <li class="layui-nav-item">
                <a href="javascript:;">欢迎管理员:<c:out value="${sessionScope.user.userName}"/></a>
                <dl class="layui-nav-child">
                  <dd><a href="<%=request.getContextPath() %>/admin/toMain">去管理页面</a></dd>
                  <dd><a href="<%=request.getContextPath() %>/logout">退出</a></dd>
                </dl>
              </li>
            </c:otherwise>
          </c:choose>
        </ul>
      </div>
    </div>
  </header>
  <main>
    <!--默认显示的页面,根据登录与否以及登录的用户来显示-->
    <c:choose>
      <c:when test="${sessionScope.user == null}">
        <iframe src="<%=request.getContextPath() %>/front/toStudentDemand" name="main"
                height="550" width="100%" frameborder="0" scrolling="no">
        </iframe>
      </c:when>
      <c:when test="${RoleEnum.STUDENT.cnName.equals(sessionScope.user.role)}">
        <iframe src="<%=request.getContextPath() %>/front/toTeacherJob" name="main"
                height="550" width="100%" frameborder="0" scrolling="no">
        </iframe>
      </c:when>
      <c:when test="${RoleEnum.TEACHER.cnName.equals(sessionScope.user.role)}">
        <iframe src="<%=request.getContextPath() %>/front/toStudentDemand" name="main"
                height="550" width="100%" frameborder="0" scrolling="no">
        </iframe>
      </c:when>
      <c:otherwise>
        <iframe src="<%=request.getContextPath() %>/front/toStudentDemand" name="main"
                height="550" width="100%" frameborder="0" scrolling="no">
        </iframe>
      </c:otherwise>
    </c:choose>
  </main>
</div>

</body>
</html>
